home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / progutil / stdwin.zoo / tools / endian.c next >
Encoding:
C/C++ Source or Header  |  1990-03-30  |  260 b   |  26 lines

  1. /* Determine byte order. */
  2.  
  3. #include "endian.h"
  4.  
  5. int endian;
  6.  
  7. void endianism()
  8. {
  9.     union {
  10.         short s;
  11.         char c[2];
  12.     } u;
  13.     
  14.     u.c[0]= 1;
  15.     u.c[1]= 2;
  16.     
  17.     switch (u.s) {
  18.     case 0x0201:
  19.         endian= LIL_ENDIAN;
  20.         break;
  21.     case 0x0102:
  22.         endian= BIG_ENDIAN;
  23.         break;
  24.     }
  25. }
  26.